<?php

namespace App\Admin\Controllers;

use App\Models\PointGoodsOrder;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class PointGoodsOrderController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '积分商品订单';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new PointGoodsOrder());

        $grid->column('name', __('Name'));
        $grid->column('mobile', __('Mobile'));
        $grid->column('point_goods_id', __('Point goods id'));
        $grid->column('number', __('Number'));
        $grid->column('remark', __('Remark'));
        $grid->column('status', __('Status'));
        $grid->column('created_at', __('Created at'));
		
        $grid->disableCreateButton();
        $grid->filter(function ($filter) {
        	$filter->disableIdFilter();
        	$filter->like('name', __('Name'));
        	$filter->like('mobile', __('Mobile'));
        });
        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(PointGoodsOrder::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('name', __('Name'));
        $show->field('mobile', __('Mobile'));
        $show->field('point_goods_id', __('Point goods id'));
        $show->field('number', __('Number'));
        $show->field('remark', __('Remark'));
        $show->field('status', __('Status'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new PointGoodsOrder());

        $form->text('name', __('Name'));
        $form->number('mobile', __('Mobile'));
        $form->number('point_goods_id', __('Point goods id'));
        $form->number('number', __('Number'));
        $form->text('remark', __('Remark'));
        $form->switch('status', __('Status'));
		
        $form->footer(function (Form\Footer $footer) {
        	$footer->disableSubmit();
        	$footer->disableCreatingCheck();
        	$footer->disableEditingCheck();
        });
        return $form;
    }
}
